1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module sourceview.SnippetChunk;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import glib.c.functions;
30 private import gobject.ObjectG;
31 private import sourceview.SnippetContext;
32 private import sourceview.c.functions;
33 public  import sourceview.c.types;
34 
35 
36 /**
37  * A chunk of text within the source snippet.
38  * 
39  * The `GtkSourceSnippetChunk` represents a single chunk of text that
40  * may or may not be an edit point within the snippet. Chunks that are
41  * an edit point (also called a tab stop) have the
42  * [property@SnippetChunk:focus-position] property set.
43  */
44 public class SnippetChunk : ObjectG
45 {
46 	/** the main Gtk struct */
47 	protected GtkSourceSnippetChunk* gtkSourceSnippetChunk;
48 
49 	/** Get the main Gtk struct */
50 	public GtkSourceSnippetChunk* getSnippetChunkStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return gtkSourceSnippetChunk;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gtkSourceSnippetChunk;
61 	}
62 
63 	/**
64 	 * Sets our main struct and passes it to the parent class.
65 	 */
66 	public this (GtkSourceSnippetChunk* gtkSourceSnippetChunk, bool ownedRef = false)
67 	{
68 		this.gtkSourceSnippetChunk = gtkSourceSnippetChunk;
69 		super(cast(GObject*)gtkSourceSnippetChunk, ownedRef);
70 	}
71 
72 
73 	/** */
74 	public static GType getType()
75 	{
76 		return gtk_source_snippet_chunk_get_type();
77 	}
78 
79 	/**
80 	 * Create a new `GtkSourceSnippetChunk` that can be added to
81 	 * a [class@Snippet].
82 	 *
83 	 * Throws: ConstructionException GTK+ fails to create the object.
84 	 */
85 	public this()
86 	{
87 		auto __p = gtk_source_snippet_chunk_new();
88 
89 		if(__p is null)
90 		{
91 			throw new ConstructionException("null returned by new");
92 		}
93 
94 		this(cast(GtkSourceSnippetChunk*) __p);
95 	}
96 
97 	/**
98 	 * Copies the source snippet.
99 	 *
100 	 * Returns: A #GtkSourceSnippetChunk
101 	 */
102 	public SnippetChunk copy()
103 	{
104 		auto __p = gtk_source_snippet_chunk_copy(gtkSourceSnippetChunk);
105 
106 		if(__p is null)
107 		{
108 			return null;
109 		}
110 
111 		return ObjectG.getDObject!(SnippetChunk)(cast(GtkSourceSnippetChunk*) __p, true);
112 	}
113 
114 	/**
115 	 * Gets the context for the snippet insertion.
116 	 *
117 	 * Returns: A #GtkSourceSnippetContext
118 	 */
119 	public SnippetContext getContext()
120 	{
121 		auto __p = gtk_source_snippet_chunk_get_context(gtkSourceSnippetChunk);
122 
123 		if(__p is null)
124 		{
125 			return null;
126 		}
127 
128 		return ObjectG.getDObject!(SnippetContext)(cast(GtkSourceSnippetContext*) __p);
129 	}
130 
131 	/**
132 	 * Gets the [property@SnippetChunk:focus-position].
133 	 *
134 	 * The focus-position is used to determine how many tabs it takes for the
135 	 * snippet to advanced to this chunk.
136 	 *
137 	 * A focus-position of zero will be the last focus position of the snippet
138 	 * and snippet editing ends when it has been reached.
139 	 *
140 	 * A focus-position of -1 means the chunk cannot be focused by the user.
141 	 *
142 	 * Returns: the focus-position
143 	 */
144 	public int getFocusPosition()
145 	{
146 		return gtk_source_snippet_chunk_get_focus_position(gtkSourceSnippetChunk);
147 	}
148 
149 	/**
150 	 * Gets the specification for the chunk.
151 	 *
152 	 * The specification is evaluated for variables when other chunks are edited
153 	 * within the snippet context. If the user has changed the text, the
154 	 * [property@SnippetChunk:text] and [property@SnippetChunk:text-set] properties
155 	 * are updated.
156 	 *
157 	 * Returns: the specification, if any
158 	 */
159 	public string getSpec()
160 	{
161 		return Str.toString(gtk_source_snippet_chunk_get_spec(gtkSourceSnippetChunk));
162 	}
163 
164 	/**
165 	 * Gets the [property@SnippetChunk:text] property.
166 	 *
167 	 * The text property is updated when the user edits the text of the chunk.
168 	 * If it has not been edited, the [property@SnippetChunk:spec] property is
169 	 * returned.
170 	 *
171 	 * Returns: the text of the chunk
172 	 */
173 	public string getText()
174 	{
175 		return Str.toString(gtk_source_snippet_chunk_get_text(gtkSourceSnippetChunk));
176 	}
177 
178 	/**
179 	 * Gets the [property@SnippetChunk:text-set] property.
180 	 *
181 	 * This is typically set when the user has edited a snippet chunk.
182 	 */
183 	public bool getTextSet()
184 	{
185 		return gtk_source_snippet_chunk_get_text_set(gtkSourceSnippetChunk) != 0;
186 	}
187 
188 	/** */
189 	public string getTooltipText()
190 	{
191 		return Str.toString(gtk_source_snippet_chunk_get_tooltip_text(gtkSourceSnippetChunk));
192 	}
193 
194 	/** */
195 	public void setContext(SnippetContext context)
196 	{
197 		gtk_source_snippet_chunk_set_context(gtkSourceSnippetChunk, (context is null) ? null : context.getSnippetContextStruct());
198 	}
199 
200 	/**
201 	 * Sets the [property@SnippetChunk:focus-position] property.
202 	 *
203 	 * The focus-position is used to determine how many tabs it takes for the
204 	 * snippet to advanced to this chunk.
205 	 *
206 	 * A focus-position of zero will be the last focus position of the snippet
207 	 * and snippet editing ends when it has been reached.
208 	 *
209 	 * A focus-position of -1 means the chunk cannot be focused by the user.
210 	 *
211 	 * Params:
212 	 *     focusPosition = the focus-position
213 	 */
214 	public void setFocusPosition(int focusPosition)
215 	{
216 		gtk_source_snippet_chunk_set_focus_position(gtkSourceSnippetChunk, focusPosition);
217 	}
218 
219 	/**
220 	 * Sets the specification for the chunk.
221 	 *
222 	 * The specification is evaluated for variables when other chunks are edited
223 	 * within the snippet context. If the user has changed the text, the
224 	 * [property@SnippetChunk:text and] [property@SnippetChunk:text-set] properties
225 	 * are updated.
226 	 *
227 	 * Params:
228 	 *     spec = the new specification for the chunk
229 	 */
230 	public void setSpec(string spec)
231 	{
232 		gtk_source_snippet_chunk_set_spec(gtkSourceSnippetChunk, Str.toStringz(spec));
233 	}
234 
235 	/**
236 	 * Sets the text for the snippet chunk.
237 	 *
238 	 * This is usually used by the snippet engine to update the text, but may
239 	 * be useful when creating custom snippets to avoid expansion of any
240 	 * specification.
241 	 *
242 	 * Params:
243 	 *     text = the text of the property
244 	 */
245 	public void setText(string text)
246 	{
247 		gtk_source_snippet_chunk_set_text(gtkSourceSnippetChunk, Str.toStringz(text));
248 	}
249 
250 	/**
251 	 * Sets the [property@SnippetChunk:text-set] property.
252 	 *
253 	 * This is typically set when the user has edited a snippet chunk by the
254 	 * snippet engine.
255 	 *
256 	 * Params:
257 	 *     textSet = the property value
258 	 */
259 	public void setTextSet(bool textSet)
260 	{
261 		gtk_source_snippet_chunk_set_text_set(gtkSourceSnippetChunk, textSet);
262 	}
263 
264 	/** */
265 	public void setTooltipText(string tooltipText)
266 	{
267 		gtk_source_snippet_chunk_set_tooltip_text(gtkSourceSnippetChunk, Str.toStringz(tooltipText));
268 	}
269 }